/**
 * Notes: 车辆管理模块业务逻辑
 * Ver : CCMiniCloud Framework 2.0.1 ALL RIGHTS RESERVED BY cclinux0730 (wechat)
 * author: bqchen
 * Date: 2022-06-24 07:48:00 
 */

const BaseBiz = require('../../../comm/biz/base_biz.js');
const projectSetting = require('../public/project_setting.js');
const formSetHelper = require('../../../cmpts/public/form/form_set_helper.js');

class AdminCarBiz extends BaseBiz {
	static initFormData(id = '') {
		return {
			id,
			fields: projectSetting.CAR_FIELDS,
			formTitle: '',
			formOrder: 9999,
			formSeatCnt: 20,
			formForms: []
		}
	}
	static getSeatInfo(val) {
		let seatCnt = 0;
		let seatList = [];
		for(let k = 0; k < (val || []).length; k ++) {
			let arr = (val[k].title || '').split('|')
			seatCnt += arr.length
			seatList = seatList.concat(arr)
		}
		return {
			seatCnt,
			seatList
		}
	}
}

AdminCarBiz.CHECK_FORM = {
	title: 'formTitle|must|string|min:2|max:50|name=车牌号',
	order: 'formOrder|must|int|min:0|max:9999|name=排序号',
	seatCnt: 'formSeatCnt|must|int|name=车辆座位数量',
	seatList: 'formSeatList|must|array|name=车辆座位列表',
	forms: 'formForms|must|array|name=车辆表单',
};

module.exports = AdminCarBiz;